﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Entity.MsgEntity
{
    [Serializable]
    public class MessageGroupEntity
    {
        private string uid;
        /// <summary>
        /// 聊天对象编号
        /// </summary>
        public string Uid
        {
            get { return uid; }
            set { uid = value; }
        }

        private string friendName;

        /// <summary>
        /// 聊天对象名字
        /// </summary>
        public string FriendName
        {
            get { return friendName; }
            set { friendName = value; }
        }

        /// <summary>
        /// 信息组号
        /// </summary>
        private string threadMid;

        public string ThreadMid
        {
            get { return threadMid; }
            set { threadMid = value; }
        }

        private string threadUrl;

        /// <summary>
        /// 短信组地址
        /// </summary>
        public string ThreadUrl
        {
            get { return threadUrl; }
            set 
            {
                Regex regex = new Regex("thread_mid=(?<threadMid>\\d+)&pos=");
                MatchCollection matchs;
                matchs = regex.Matches(value);
                if (matchs.Count > 0)
                    this.ThreadMid = matchs[0].Groups["threadMid"].Value;

                threadUrl = value; 
            }
        }

        private List<MessageEntity> messageList = new List<MessageEntity>();
        /// <summary>
        /// 聊天内容
        /// </summary>
        public List<MessageEntity> MessageList
        {
            get { return messageList; }
            set { messageList = value; }
        }
    }
}
